package com.sf.fy.uav.applet.tool;

import com.sf.fy.uav.order.entity.OrderInfo;
import com.sf.fy.uav.order.mapper.OrderInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author 01430312
 */
@RestController
@RequestMapping("/home/video/")
public class VideoNameController {

    @Value("${video.public_url:https://ie-uocs-core-shenzhen-futian1-oss.sf-express.com/v1.2/AUTH_IE-UOCS-CORE/sfosspublic001/applet/fly_video/}")
    private String publicUrl;


    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @GetMapping("get-name")
    public String getName(@RequestParam String orderId) {
        OrderInfo orderinfo = orderInfoMapper.selectById(orderId);
        if (ObjectUtils.isEmpty(orderinfo)) {
            throw new RuntimeException("订单不存在");
        }
        return publicUrl + orderinfo.getTakeoffConnId() + ".mp4";
    }

}